<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
       <input type="text" v-model="name">
       <input type="text" v-model="user.username">
    </div>
</body>
<script>
    new Vue({
        el:'#app',
        data:{ // 普通属性
           name:'tom',
           user:{
                id:1,
                username:'admin',
                password:'123'
           }
        },
        watch:{ // 监视器
            name:function(newValue,oldValue){
                console.log(newValue,oldValue)
            },
            user:{
                handler:function(newValue,oldValue){
                    console.log(newValue,oldValue)
                },
                deep:true, // 深度监视
                immediate: true 
            } 
        }
    })
</script>
</html>